package com.trkj.controllers;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.DepositTable;
import com.trkj.pojos.DepositreturnTable;
import com.trkj.pojos.DepositurgeTable;
import com.trkj.service.DepositService;
@Controller
public final class HospitalLiveDepositController {
	@Autowired
	private DepositService depositService;
	/**
	 * 根据住院号查询住院押金
	 * @param liveID
	 * @return
	 */
	@RequestMapping("/to_queryDepositByLiveID")
	@ResponseBody
	public List<DepositTable> queryDepositByLiveID(String liveID){
		List<DepositTable> depositTable = depositService.queryDepositByLiveID(liveID);
		return depositTable;
	}
	/**
	 * 动态查询住院押金
	 * @param page
	 * @param rows
	 * @param depositstatus
	 * @param afterLivedate
	 * @param beforeLivedate
	 * @return
	 */
	@RequestMapping("/to_fuzzyqueryDepositt")
	@ResponseBody
	public Map<String,Object> fuzzyqueryDeposit(int page,int rows,String depositstatus,
			String afterLivedate,String beforeLivedate){
		
		Map<String,Object> map = new HashMap<>();
		map.put("depositstatus", depositstatus);
		map.put("afterLivedate", afterLivedate);
		map.put("beforeLivedate", beforeLivedate);
		return depositService.fuzzyQueryDeposit(page, rows, map);
	}
	/**
	 * 跳转收取押金界面
	 * @return
	 */
	@RequestMapping("/to_hspt_live_deposit")
	public String to_hspt_live_deposit( ){
		return "hspt_live_deposit_management";
		
	}
	/**
	 * 收取押金
	 * @param depositID
	 * @param takeMoney
	 * @param admin
	 */
	@RequestMapping("/to_chargedeposit")
	public void chargeDeposit(String depositID,Double takeMoney,String admin){
		depositService.chargeDeposit(depositID, takeMoney, admin);
	}
	/**
	 * 跳转押金收取界面
	 * @return
	 */
	@RequestMapping("/to_hspt_charge_deposit")
	public String to_hspt_charge_deposit( ){
		return "hspt_live_deposit_charge";
	}
	/**
	 * 跳转押金退还界面
	 * @return
	 */
	@RequestMapping("/to_hspt_return_deposit")
	public String to_hspt_return_deposit( ){
		return "hspt_return_deposit";
		
	}
	/**
	 * 生成押金退还号
	 * @return
	 */
	@RequestMapping("/to_initReturnDepositID")
	@ResponseBody
	public Map<String,Object> initReturnDepositID(){
		String ReturnDepositID = depositService.createRetuenDepositID();
		Map<String,Object> map = new HashMap<>();
		map.put("ReturnID", ReturnDepositID);
		return map;
	}
	/**
	 * 添加退回押金记录
	 * @param depositreturnTable
	 */
	@RequestMapping("/to_addReturnDeposit")
	public void addReturnDeposit(DepositreturnTable depositreturnTable){
		depositService.addNewDepositReturn(depositreturnTable);
	}
	/**
	 * 动态分页查询押金退还
	 * @param page
	 * @param rows
	 * @param afterLivedate
	 * @param beforeLivedate
	 * @return
	 */
	@RequestMapping("/to_fuzzyQueryReturnDeposit")
	@ResponseBody
	public Map<String,Object> fuzzyQueryReturnDeposit(int page,int rows,String afterTime,String beforeTime){
		Map<String,Object> map = new HashMap<>();
		map.put("afterTime", afterTime);
		map.put("beforeTime", beforeTime);
		return depositService.fuzzyqueryReturnDeposit(page, rows,map);
	}
	/**
	 * 跳转押金催缴界面
	 * @return
	 */
	@RequestMapping("/to_hspt_deposit_urge")
	public String to_hspt_deposit_urge( ){
		return "hspt_live_deposit_urge";
		
	}
	
	/**
	 * 动态分页查询押金催缴
	 * @param page
	 * @param rows
	 * @param afterTime
	 * @param beforeTime
	 * @return
	 */
	@RequestMapping("/to_fuzzyQueryUrgeDeposit")
	@ResponseBody
	public Map<String,Object> fuzzyQueryUrgeDeposit(int page,int rows,String afterTime,String beforeTime){
		Map<String,Object> map = new HashMap<>();
		map.put("afterTime", afterTime);
		map.put("beforeTime", beforeTime);
		return depositService.fuzzyqueryUrgeDeposit(page, rows, map);
	}
	
	/**
	 * 生成押金退还号
	 * @return
	 */
	@RequestMapping("/to_initUrgeDepositID")
	@ResponseBody
	public Map<String,Object> initUrgeDepositID(){
		String ReturnDepositID = depositService.createUrgeDepositID();
		Map<String,Object> map = new HashMap<>();
		map.put("UrgeDepositID", ReturnDepositID);
		return map;
	}
	
	/**
	 * 添加催缴押金记录
	 * @param depositreturnTable
	 */
	@RequestMapping("/to_addUrgeDeposit")
	public void addUrgeDeposit(DepositurgeTable depositurgeTable){
		depositService.addUrgeDeposit(depositurgeTable);
	}

}
